package com.business.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * Created by mengdexuan on 2017/1/16 16:51.
 */
public class DerbyConn {

	private static Connection conn = null;

	public static synchronized final Connection getConn() {
		try {
			if (conn!=null)return conn;
			try {
				Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
				conn = DriverManager.getConnection("jdbc:derby:db/derby_db;create=true");
			} catch (SQLException e) {
				e.printStackTrace();
			}
			return conn;
		} catch (Exception e) {
			throw new RuntimeException("获取 derbyConn 失败！", e);
		}
	}

}
